import { EventKey } from '../common/Key';
cc.Class({
    extends: require('BaseUI'),

    properties: {
        
    },

    onLoad(){
        this._super();
        this.nodMask = this.node.getChildByName('nodMask');
        this.nodCore = this.node.getChildByName('nodCore');
    },

    onClose() {
        G.ui.closeUI(this.node);
    },

    onEnter(args) {
        G.onFire.fire(EventKey.EVENT_CANCEL_BLOCK_INPUT);
        this.enterArgs = args;
        this.nodMask.on('touchstart', this.onTouchStart, this);
        this.show();
        G.onFire.fire(EventKey.EVENT_ENTER_PANEL);
    },

    onExit(cb) {
        this.nodMask.off('touchstart', this.onTouchStart, this);
        this.hide(cb);
        G.onFire.fire(EventKey.EVENT_EXIT_PANEL);
    },

    show() {
        let action = cc.sequence(
            cc.scaleTo(0.1, 1.02, 1.02),
            cc.scaleTo(0.1, 1, 1)
        )
        this.nodCore.runAction(action);
    },

    hide(cb) {
        let action = cc.sequence(
            cc.scaleTo(0.1, 1.02, 1.02),
            cc.scaleTo(0.1, 0, 0),
            cc.callFunc(() => {
                cb && cb();
            })
        )
        this.nodCore.runAction(action);
    },
    onTouchStart() {
        this.onClose();
    },
});